home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / asmflo25.zip / SAMPLE.ASM < prev   
Assembly Source File  |  1991-06-10  |  6KB  |  226 lines

  1. title   ASMFLOW_sample_source_file
  2.  
  3. dosseg
  4.  
  5. .model small
  6.  
  7. .code
  8.  
  9. EXTRN edit_warning             : near
  10. EXTRN insert_blank_line        : near
  11. EXTRN adjust_line_misspellings : near
  12.  
  13. ;--------------------------------------------------------------------
  14. ; some code samples to show flow charting and
  15. ; tree diagram features of ASMFLOW
  16. ;
  17. ; NOTE: include files deleted, this file will not assemble
  18. ;--------------------------------------------------------------------
  19.  
  20. PUBLIC join_lines
  21. join_lines PROC near
  22.  
  23.               push   cx
  24.               push   dx
  25.               push   si
  26.               push   di
  27.  
  28.               mov    ax, bp
  29.               sar    ax, 1
  30.               cmp    ax, edit_num_lines
  31.               jl     jl_0
  32.               jmp    jl_x
  33. jl_0:
  34.               mov    dx, ds:edit_line_nc[bp]
  35.               cmp    dx, max_line_length
  36.               jle    jl_1
  37.               mov    al, .ew_join_ln_max_len
  38.               call   edit_warning
  39.               jmp    jl_x
  40. jl_1:
  41.               mov    cx, ds:edit_line_nc[bp+2]
  42.               push   cx                       ; save num chars next line
  43.               push   ax                       ; save next line number
  44.               mov    dx, 0
  45.               mul    max_line_length
  46. jl_loop_1:
  47.               mov    edit_buffer[di], al
  48.               inc    di
  49.               loop   jl_loop_1
  50.  
  51. ; adjust misspelling ptrs for joined line
  52.  
  53.               push   bp
  54.               add    bp, 2
  55.               mov    dx, ds:edit_line_nc[bp-2]
  56.               sub    dx, eol_nc
  57.               sub    dx, max_line_length      ; amount to add (neg so subtract)
  58.               call   adjust_line_misspellings
  59.               pop    bp
  60.  
  61. ; delete next line
  62.  
  63.               pop    ax                       ; next line number
  64.               call   delete_edit_line
  65.  
  66. ; update number characters for joined line
  67.  
  68.               pop    cx                       ; num chars line appended
  69.               add    cx, ds:edit_line_nc[bp]
  70.               sub    cx, eol_nc               ; eol chars are overlayed
  71.               mov    ds:edit_line_nc[bp], cx
  72.  
  73. ; update display from joined line to last line
  74.  
  75.               sar    ax, 1
  76.               mov    cx, edit_num_lines
  77.               sub    cx, ax
  78.               inc    cx
  79. jl_loop_3:
  80.               call   edit_line_out
  81.               loop   jl_loop_3
  82. jl_x:
  83.               pop    di
  84.               pop    si
  85.               pop    dx
  86.               pop    cx
  87.               ret
  88.  
  89. join_lines ENDP
  90.  
  91.  
  92. PUBLIC break_current_line
  93. break_current_line PROC
  94.  
  95.               push   cx
  96.               push   dx
  97.               push   di
  98.               push   si
  99.  
  100.               mov    dx, 0
  101.               mov    ax, bx
  102.               div    max_line_length
  103.               sub    cx, dx
  104.               cmp    cx, eol_nc
  105.               jg     bcl_0
  106.               mov    al, .ew_brk_line_aft_eol
  107.               call   edit_warning
  108.               jmp    bcl_x
  109.  
  110. bcl_0:
  111.              push    ax
  112.              mov     ax, edit_num_lines
  113.              cmp     ax, edit_max_num_lines
  114.              jl      bcl_1
  115.              pop     ax
  116.              mov     al, .ew_brk_line_max_ln
  117.              call    edit_warning
  118.              jmp     bcl_x
  119.  
  120. bcl_1:
  121.              mov     ax, bp
  122.              sar     ax, 1
  123.              inc     ax
  124.              call    insert_blank_line
  125.  
  126.              pop     ax
  127.              push    dx
  128.              mov     ds:edit_line_nc[bp+2], cx
  129.              mul     max_line_length
  130.              mov     di, ax                  ; offset to start next line
  131.              mov     si, bx
  132.              pop     dx
  133.              push    ax                      ; save offset to next line
  134. bcl_loop_1:
  135.              mov     al, edit_buffer[si]
  136.              mov     edit_buffer[si], ' '
  137.              mov     edit_buffer[di], al
  138.              inc     si
  139.              inc     di
  140.              loop    bcl_loop_1
  141.  
  142. ;      update offsets for misspellings on new line
  143.  
  144.              mov     ax, max_line_length
  145.              sub     ax, dx
  146.              mov     dx, ax
  147.              call    adjust_line_misspellings
  148.              call    join_lines
  149.  
  150. ;      add eol characters to end of current line
  151. ;      update cursor position to start of next line
  152.  
  153.              mov     cx, eol_nc
  154.              mov     si, 0
  155.              mov     di, bx
  156. bcl_loop_2:
  157.              mov     al, eol_chars[si]
  158.              mov     edit_buffer[di], al
  159.              inc     si
  160.              inc     di
  161.              loop    bcl_loop_2
  162.              pop     bx                    ; saved offset to start next line
  163.  
  164. ;  update display from current line to end of edit lines
  165.  
  166.              mov     ax, bp
  167.              mov     cx, edit_num_lines
  168.              sub     cx, ax
  169. bcl_loop_3:
  170.              call    edit_line_out
  171.              inc     ax
  172.              loop    bcl_loop_3
  173. bcl_x:
  174.              call    join_lines
  175.              ret
  176.              pop     si
  177.              pop     di
  178.              pop     dx
  179.              pop     cx
  180.              ret
  181.  
  182. break_current_line ENDP
  183.  
  184.  
  185. ; demo of more complex branching for flow charts
  186.  
  187. orphan proc near
  188.  
  189.        push cx
  190.  
  191.        mov  cx, 10
  192.        cmp  ax, -1
  193. top1:
  194.        je   down1
  195.        cmp  ax, 0
  196. up1:
  197.        jc   down1
  198.        je   down2
  199.        inc  ax
  200.        jz   down3
  201.        inc  ax
  202.        jz   down1
  203.        inc  cx
  204. down1:
  205.        cmp  cx, 2
  206.        jc   down2
  207.        je   up1
  208.        inc  ax
  209.        jz   down2
  210.        jc   down3
  211.        add  ax, bx
  212. down2:
  213.        jc   down4
  214.        inc  cx
  215. down3:
  216.        loop top1
  217. up2:
  218.        ret
  219.        ret
  220. down4:
  221.        jmp  up2
  222.  
  223. orphan endp
  224.  
  225.          end
  226.